package com.veryedu.hibernate.biz.bean;

import java.sql.Timestamp;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;

import com.veryedu.hibernate.commons.Constant;

public class DateBean implements Comparable<DateBean>{
	private String date;
	private List<TimeBean> times = new ArrayList<TimeBean>();
	public String getDate() {
		return date;
	}
	public void setDate(String date) {
		this.date = date;
	}
	public List<TimeBean> getTimes() {
		return times;
	}
	public void setTimes(List<TimeBean> times) {
		this.times = times;
	}
	
	@Override
	public int compareTo(DateBean o) {
		int result = 0;
		try {
			
			Timestamp thisDate = new Timestamp(Constant.YYYY_MM_DD.parse(this.date).getTime());
			Timestamp otherDate = new Timestamp(Constant.YYYY_MM_DD.parse(o.getDate()).getTime());
			
			if(thisDate.before(otherDate)) result = -1;
			else if(thisDate.after(otherDate)) result = 1;
			else result = 0;
			
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return result;
	}
	
	
}
